﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using GomMinhLongDO;
using GomMinhLongBL;

namespace GomMinhLong.Module
{
    public partial class ucBreadcrumb : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = Request.Url.AbsolutePath;
            url = url.Substring(1, url.Length - 1);
            string url1 = url.Replace(".", "/");
            string Module = url1.Substring(0, url1.IndexOf("/"));
          
                lbHome.Text = "Trang chủ ";

                if (Module == "Gioi-Thieu")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        int ID = int.Parse(Request.QueryString["ID"]);
                        string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = ID }).Title;
                        lblTitle.Text = "<a href='/Gioi-Thieu/" + Request.QueryString["ID"].ToString() + "/Gioi-Thieu.htm'>" + Title + "</a>";
                    }
                }
                else if (Module == "Dich-Vu")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        int ID = int.Parse(Request.QueryString["ID"]);
                        string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = ID }).Title;

                        lblTitle.Text = "<a href='/Dich-Vu/" + Request.QueryString["ID"].ToString() + "/Dich-Vu.htm'>" + Title + "</a>";
                    }
                }
                else if (Module == "Tin-Tuc")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        int ID = int.Parse(Request.QueryString["ID"]);
                        string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = ID }).Title;

                        lblTitle.Text = "<a href='/Tin-Tuc/" + Request.QueryString["ID"].ToString() + "/Tin-Tuc.htm'>" + Title + "</a>";
                    }
                }

                else if (Module == "Khuyen-Mai")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        int ID = int.Parse(Request.QueryString["ID"]);
                        string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = ID }).Title;

                        lblTitle.Text = "<a href='/Khuyen-Mai/" + Request.QueryString["ID"].ToString() + "/Khuyen-Mai.htm'>" + Title + "</a>";
                    }
                }
                else if (Module == "Tu-Khoa-San-Pham")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        lblTitle.Text = "<a href='/Tu-Khoa-San-Pham/" + Request.QueryString["ID"].ToString() + "/Tim-Kiem.htm'>Tag: " + Request.QueryString["ID"].ToString() + "</a>";
                    }
                }
                else if (Module == "Tu-Khoa-Tim-Tuc")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        lblTitle.Text = "<a href='/Tu-Khoa-Tim-Tuc/" + Request.QueryString["ID"].ToString() + "/Tim-Kiem.htm'>Tag: " + Request.QueryString["ID"].ToString() + "</a>";
                    }
                }
                else if (Module == "Tu-Khoa-Khuyen-Mai")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        lblTitle.Text = "<a href='/Tu-Khoa-Khuyen-Mai/" + Request.QueryString["ID"].ToString() + "/Tim-Kiem.htm'>Tag: " + Request.QueryString["ID"].ToString() + "</a>";
                    }
                }
                else if (Module == "San-Pham")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        if (Request.QueryString["ID"].ToString() == "All")
                        {
                            lblTitle.Text = "<a href='/San-Pham/All/San-Pham.htm'>Sản phẩm </a>";
                        }
                        else
                        {
                            int ID = int.Parse(Request.QueryString["ID"]);
                            string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = ID }).Title;

                            lblTitle.Text = "<a href='/San-Pham/" + Request.QueryString["ID"].ToString() + "/Khuyen-Mai.htm'>" + Title + "</a>";
                        }
                    }
                }
                else if (Module == "Gui-Gio-Hang")
                {
                    lblTitle.Text = "<a href='/Gui-Gio-Hang.htm'>Gửi giỏ hàng</a>";
                }
                else if (Module == "Gio-Hang")
                {
                    lblTitle.Text = "<a href='/Gio-Hang.htm'>Giỏ hàng</a>";
                }
                else if (Module == "Lien-He")
                {
                    lblTitle.Text = "<a href='/Lien-He.htm'>Liên hệ</a>";
                }
                else if (Module == "Chi-Tiet-Tin-Tuc")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        int IDNews = int.Parse(Request.QueryString["ID"]);
                        string TitleNews = new cmsArticleBL().Select(new cmsArticleDO { ArticleID = IDNews }).Title;
                        int IDCategory = new cmsArticleBL().Select(new cmsArticleDO { ArticleID = IDNews }).CategoryID;
                        string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = IDCategory }).Title;

                        lblTitle.Text = "<a href='/Tin-Tuc/" + IDCategory.ToString() + "/Tin-Tuc.htm'>" + Title + "</a> » " + "<a href='/Chi-Tiet-Tin-Tuc/" + IDNews.ToString() + "/Chi-Tiet-Tin-Tuc.htm'>" + TitleNews + "</a>";
                    }
                }
                else if (Module == "Chi-Tiet-Khuyen-Mai")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        int IDNews = int.Parse(Request.QueryString["ID"]);
                        string TitleNews = new cmsArticleBL().Select(new cmsArticleDO { ArticleID = IDNews }).Title;
                        int IDCategory = new cmsArticleBL().Select(new cmsArticleDO { ArticleID = IDNews }).CategoryID;
                        string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = IDCategory }).Title;

                        lblTitle.Text = "<a href='/Khuyen-Mai/" + IDCategory.ToString() + "/Khuyen-Mai.htm'>" + Title + "</a> » " + "<a href='/Chi-Tiet-Khuyen-Mai/" + IDNews.ToString() + "/Chi-Tiet-Khuyen-Mai.htm'>" + TitleNews + "</a>";
                    }
                }
                else if (Module == "Chi-Tiet-San-Pham")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        int IDProduct = int.Parse(Request.QueryString["ID"]);
                        string TitleProduct = new cmsSanPhamBL().Select(new cmsSanPhamDO { SanPhamID = IDProduct }).TenSanPham;
                        int IDCategory = new cmsSanPhamBL().Select(new cmsSanPhamDO { SanPhamID = IDProduct }).LoaiSanPhamID;
                        string Title = new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = IDCategory }).Title;

                        lblTitle.Text = "<a href='/San-Pham/" + IDCategory.ToString() + "/San-Pham.htm'>" + Title + "</a> » " + "<a href='/Chi-Tiet-San-Pham/" + IDProduct.ToString() + "/Chi-Tiet-San-Pham.htm'>" + TitleProduct + "</a>";
                    }
                }
                
                else
                {
                    lblTitle.Text = "<a href='/" + Module + ".htm'>" + Module + " </a>";
                }
 
        }

        protected string FriendlyUrl(string strTitle)
        {
            return Ultility.Change_AV(strTitle);
        }
    }
}